package io.mft.commons.config.mq;

import java.util.HashMap;
import java.util.List;

import io.mft.commons.config.mq.MqConfig.ConfigValue;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class MqConfig extends HashMap<String, List<ConfigValue>>{
	
	 
	        /**
	 * @说明：TODO
	 * @字段名称 serialVersionUID
	        */  
	    
	private static final long serialVersionUID = -4820914407894457366L;
	@Getter
	@Setter
	public static class ConfigValue{
		private String pluginId;
		private String ownerPluginId;
		private String type;
		private String datasourceId;
		private List<MqQueue> queues;
		private List<MqExchange> exchanges;
		private List<MqConsumer> consumers;
		
		public void init() {
			if (queues!=null) {
				queues.forEach(q->{
					q.setDatasourceId(datasourceId);
				});			
			}
			if (exchanges!=null) {
				exchanges.forEach(e->{
					e.setDatasourceId(datasourceId);
				});
			}
			if (consumers!=null) {
				consumers.forEach(c->{
					c.setDatasourceId(datasourceId);
				});
			}

		}
	}
}
